#pragma once

#include <base/macro/aeval.h>

/* 原理是通过字符串连接构造所需的值 */

#define __LOGIC_1P(f, b)		__MCAT(__##f##_, b)
#define __LOGIC_2P(f, x, y)		__LOGIC_1P(f, __MCAT(x,y))

/* 宏逻辑运算以及IFELSE的定义，真值表 */

#define NOT(x)				__CHECK(__LOGIC_1P(NOT, x))
#define __NOT_0				__PROBE(~)

/* 取!!x */
#define TO_BOOL(x)			NOTB(NOT(x))

#define NOTB(b)				__LOGIC_1P(NOTB, b)
#define __NOTB_0			1
#define __NOTB_1			0

#define ANDB(x, y)			__LOGIC_2P(ANDB, x, y)
#define __ANDB_00			0
#define __ANDB_01			0
#define __ANDB_10			0
#define __ANDB_11			1

#define ORB(x, y)			__LOGIC_2P(ORB, x, y)
#define __ORB_00			0
#define __ORB_01			1
#define __ORB_10			1
#define __ORB_11			1

#define XORB(x, y)			__LOGIC_2P(XORB, x, y)
#define __XORB_00			0
#define __XORB_01			1
#define __XORB_10			1
#define __XORB_11			0

#define EQB(x, y)			__LOGIC_2P(EQB, x, y)
#define __EQB_00			1
#define __EQB_01			0
#define __EQB_10			0
#define __EQB_11			1
